package com.cskaoyan.config;


import org.apache.shiro.web.session.mgt.DefaultWebSessionManager;


import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import java.io.Serializable;

/**
 * Created with IntelliJ IDEA.
 *
 * @Description:
 * @Author: 周佳豪
 * @Date: 2022/04/10/16:09
 */
public class MarketSessionManager extends DefaultWebSessionManager {
    //保证认证前后session是同一个session
    @Override
    protected Serializable getSessionId(ServletRequest request, ServletResponse response) {
        //获得之前的sessionId
        HttpServletRequest httpServletRequest = (HttpServletRequest) request;
        String sessionId = httpServletRequest.getHeader("X-CskaoyanMarket-Admin-Token");
        if (sessionId != null && !"".equals(sessionId)) {

            return sessionId;
        }
        return super.getSessionId(request, response);
    }
}
